<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/2/13
 * Time: 下午7:31
 */

$str = 'Hello World! \!';
//  Hello\ World\!\ \\!
echo addcslashes( $str, ' !' ) . PHP_EOL;
//  \H\e\l\l\o \W\o\r\l\d! \\!
echo addcslashes( $str, 'A..z' ) . PHP_EOL;
//  Hello World\! \\\!
echo addcslashes( $str, '\!' ) . PHP_EOL;
//  Hello World\! \\!
echo addcslashes( $str, '!' ) . PHP_EOL;
$str = '1234567890';
//  \1\2\3\4\5\6\7\8\90
echo addcslashes( $str, '1..9' ) . PHP_EOL;
